
#
# write data with compress and base64-encode
#  

import	base64
import	zlib
import	time

def	test_read ( filename )	:
	key_prefix = 'abcdefghijklmnopqrstuvwxyz'

	records_count = 100000
	time_start = time.time()
	fh = open ( filename, 'r' )
	for i in xrange(records_count) :
		line = fh.readline()
		(key, value) = line.split()
		value = zlib.decompress ( base64.standard_b64decode( value ) )
		if key != value :
			print "key:%s\tvalue" % (key, value)

	fh.close()
	time_stop = time.time()
	time_last = time_stop - time_start
	tps = records_count / time_last
	print "records-count=%d time-last=%.3f seconds tps=%.3f" % ( records_count, time_last, tps )

if	__name__ == '__main__'	:
	filename = 'base64.dat'
	test_read ( filename )

